
* Author: Gregory Smith
* Date: December 3, 2018 
* Job: Primary Bivariate Probit Analysis (Secret But Constrained)
* Note: These models use onset year as the primary dependent variable and drop years when operations are ongoing 


clear
set more off
*\ set working directory
cd "~/Dropbox/covert_ops_paper/2019-smith-io-secret-but-constrained-replication-files/data/"

*\ open file 
 use smith_2019_secret_but_constrained_dta.dta
 


* Cross Tabulations Between the Dependent Variables 

tabulate orourke_onset major_us_onset

tabulate orourke_onset minor_us_onset

tabulate us_covert_onset major_us_onset

tabulate us_covert_onset minor_us_onset

tabulate major_us_onset minor_us_onset

tabulate mid_onset orourke_onset


* Adds Variable Labels (to be used in the Latex output) 

label variable orourke_onset   "O'Rourke Onset" 
label variable us_covert_onset   "Pooled Onset" 
label variable major_us_onset    "Major MID Onset" 
label variable minor_us_onset    "Minor MID Onset" 


label variable divided   "Divided Government" 
label variable approval_q1 "Qtr. 1 Approval"
label variable election  "Election Year"
label variable oversight_change "Oversight Change"
label variable democracy "Joint Democracy"
label variable cinc_proportion "CINC Ratio"
label variable clean_russ_inf "Active Russian Operation"
label variable orourke_peace_years "Peace Years"
label variable orourke_peace_years_2 "Peace Years Squared"
label variable orourke_peace_years_3 "Peace Years Cubed"

* US Covert Onset Peace Years
label variable us_peace_years "Peace Years"
label variable us_peace_years_2 "Peace Years Squared"
label variable us_peace_years_3 "Peace Years Cubed"


generate major_us_py_2 = major_us_py ^2
generate major_us_py_3 = major_us_py ^3


* Major MID Peace Years 
label variable major_us_py "Peace Years"
label variable major_us_py_2 "Peace Years Squared"
label variable major_us_py_3 "Peace Years Cubed"


*\ First bivariate probit model: orourke onset and major gml onset 


biprobit (orourke_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change orourke_peace_years orourke_peace_years_2 orourke_peace_years_3) ///
 (major_us_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change major_us_py major_us_py_2 major_us_py_3), vce(robust)

est sto bp1 
esttab bp1, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of O'Rourke Covert Onset and Major MID Onset") booktabs


 * Predicted marginal probabilities of y1=1 and y2=1
 predict biprob_or1, pmarg1 
 predict biprob_or2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_or_00, p00 
predict biprob_or_01, p01 
predict biprob_or_10, p10 
predict biprob_or_11, p11 

*\ Summarizing predicted values
summarize orourke_onset major_us_onset biprob_or1 biprob_or2 
summarize biprob_or_00 biprob_or_01 biprob_or_10 biprob_or_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)

*\ Second bivariate probit model: orourke and minor onset  

* Adds peace years squared and cubed 
generate minor_us_py_2 = minor_us_py^2
generate minor_us_py_3 = minor_us_py^3


* Minor MID Peace Year Labels
label variable minor_us_py "Peace Years"
label variable minor_us_py_2 "Peace Years Squared"
label variable minor_us_py_3 "Peace Years Cubed"


biprobit (orourke_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change orourke_peace_years orourke_peace_years_2 orourke_peace_years_3) ///
 (minor_us_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change minor_us_py minor_us_py_2 minor_us_py_3) , vce(robust)

est sto bp2 
esttab bp2, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of O'Rourke Covert Onset and Minor MID Onset") booktabs


 * Predicted marginal probabilities of y1=1 and y2=1
 predict biprob_ormin_1, pmarg1 
 predict biprob_ormin_2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_ormin_00, p00 
predict biprob_ormin_01, p01 
predict biprob_ormin_10, p10 
predict biprob_ormin_11, p11 

*\ Summarizing predicted values
summarize orourke_onset minor_us_onset biprob_ormin_1 biprob_ormin_2 
summarize biprob_ormin_00 biprob_ormin_01 biprob_ormin_10 biprob_ormin_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)



*\ Third bivariate probit model: pooled covert onset and major onset 
biprobit (us_covert_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change us_peace_years us_peace_years_2 us_peace_years_3) ///
 (major_us_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change major_us_py major_us_py_2 major_us_py_3) , vce(robust)

est sto bp3 


esttab bp3, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of Pooled Covert Onset and Major MID Onset") booktabs



 * Predicted marginal probabilities of y1=1 and y2=1
 predict biprob_pmaj_1, pmarg1 
 predict biprob_pmaj_2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_pmaj_00, p00 
predict biprob_pmaj_01, p01 
predict biprob_pmaj_10, p10 
predict biprob_pmaj_11, p11 

*\ Summarizing predicted values
summarize us_covert_onset major_us_onset biprob_pmaj_1 biprob_pmaj_2 
summarize biprob_pmaj_00 biprob_pmaj_01 biprob_pmaj_10 biprob_pmaj_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)


*\ Fourth bivariate probit model: pooled covert onset and minor onset 
biprobit (us_covert_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change us_peace_years us_peace_years_2 us_peace_years_3) ///
 (minor_us_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change minor_us_py minor_us_py_2 minor_us_py_3) , vce(robust) 

est sto bp4 

esttab bp4, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of Pooled Covert Onset and Minor MID Onset") booktabs


 * Predicted marginal probabilities of y1=1 and y2=1
 predict biprob_pmin_1, pmarg1 
 predict biprob_pmin_2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_pmin_00, p00 
predict biprob_pmin_01, p01 
predict biprob_pmin_10, p10 
predict biprob_pmin_11, p11 

*\ Summarizing predicted values
summarize us_covert_onset minor_us_onset biprob_pmin_1 biprob_pmin_2 
summarize biprob_pmin_00 biprob_pmin_01 biprob_pmin_10 biprob_pmin_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)
                      

*\ Fifth bivariate probit model: Orourke onset and Pooled (major + minor) US MIDs  

biprobit (orourke_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change orourke_peace_years orourke_peace_years_2 orourke_peace_years_3) ///
 (us_mid_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change us_onset_py us_onset_py_2 us_onset_py_3), vce(robust)

est sto bp5 
esttab bp5, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of O'Rourke Covert Operations and Major US MIDs") booktabs


 * Predicted marginal probabilities of y1=1 and y2=1
 predict biprob_or_pool_1, pmarg1 
 predict biprob_or_pool_2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_or_pool_00, p00 
predict biprob_or_pool_01, p01 
predict biprob_or_pool_10, p10 
predict biprob_or_pool_11, p11 

*\ Summarizing predicted values
summarize orourke_onset us_mid_onset biprob_or_pool_1 biprob_or_pool_2 
summarize biprob_or_pool_00 biprob_or_pool_01 biprob_or_pool_10 biprob_or_pool_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)


*\ Sixth bivariate probit model: Pooled Covert Onset and Pooled (major + minor) US MIDs  

biprobit (us_covert_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change us_peace_years us_peace_years_2 us_peace_years_3) ///
 (us_mid_onset = i.divided i.election approval_q1 i.democracy cinc_proportion i.clean_russ_inf i.oversight_change us_onset_py us_onset_py_2 us_onset_py_3), vce(robust) 


est sto bp6
esttab bp6, se label nobaselevels starlevels(* 0.05) unstack title("Bivariate Probit Model of O'Rourke Covert Operations and Major US MIDs") booktabs


* Predicted marginal probabilities of y1=1 and y2=1
predict biprob_pool_pool_1, pmarg1 
predict biprob_pool_pool_2, pmarg2 

* Predicted joint probabilities of y1=0 and y2=0, y1=0 and y2=1, y1=1 and y2=0, and y1=1 and y2=1
predict biprob_pool_pool_00, p00 
predict biprob_pool_pool_01, p01 
predict biprob_pool_pool_10, p10 
predict biprob_pool_pool_11, p11 

*\ Summarizing predicted values
summarize us_covert_onset us_mid_onset biprob_pool_pool_1 biprob_pool_pool_2 
summarize biprob_pool_pool_00 biprob_pool_pool_01 biprob_pool_pool_10 biprob_pool_pool_11

* Marginal effects 
margins, dydx(*) atmeans predict(p00)
margins, dydx(*) atmeans predict(p01)
margins, dydx(*) atmeans predict(p10)
margins, dydx(*) atmeans predict(p11)
